package com.qth.valet.common.utils;

import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;

public class CommonUtil {

    public static boolean isDriverOnline(Integer status) {
        return Arrays.asList(StatusConstants.DRIVER_ONLINE, StatusConstants.DRIVER_RECEIVE).contains(status);
    }

    public static String getPhoneSuffix(String phone, Integer len) {
        return phone.substring(phone.length() - len);
    }

    public static Date getDateAfterOneMonth(Date baseDate) {
        Calendar calendar = Calendar.getInstance();
        if (baseDate != null && baseDate.after(new Date())) {
            calendar.setTime(baseDate);
        };
        calendar.add(Calendar.MONTH, 1);
        return calendar.getTime();
    }

    public static Date getDateAfterOneYear(Date baseDate) {
        Calendar calendar = Calendar.getInstance();
        if (baseDate != null && baseDate.after(new Date())) {
            calendar.setTime(baseDate);
        };
        calendar.add(Calendar.YEAR, 1);
        return calendar.getTime();
    }

}
